<?php

/**
 * @author huuvung
 * @copyright 2012
 */
 
defined('DSVH') or die('Restricted access');

//add 
function insertphongnghi($local){
    mysql_query("insert phong_nghi set 
    title = '".$local['title']."',
    menu = '".$local['menu']."',
    sap_xep = '".$local['sap_xep']."',
    edit_date = NOW(),
    content = '".$local['content']."'
    ", dbconnect());
}

//list 
function getListphongnghi($start,$limit)
    {
        $local_list = mysql_query("SELECT * FROM phong_nghi order by sap_xep asc
        limit ".(int)$start.",".(int)$limit."
        ", dbconnect());
        $result = array();
        while ($local = mysql_fetch_array($local_list)){
            $result []= $local;
        }
        return $result;
    }
//ham lay du lieu 
function getphongnghi($id)
    {
    $pro = mysql_query("select * from phong_nghi
    where phong_nghi_id = '".(int)$id."'", dbconnect());
    return mysql_fetch_array($pro);
    }
    
function getinfo($alias)
    {
    $pro = mysql_query("select * from phong_nghi
    where alias = '".$alias."'", dbconnect());
    return mysql_fetch_array($pro);
    }
    
//getListphongnghiVoiThamSoNangCao

function getListphongnghiVoiThamSoNangCao($local){
        $sql = "select * from phong_nghi WHERE LCASE(title) like LCASE('%".$local['title']."%')";
         
        $local_list = mysql_query($sql, dbconnect());    
        
        $result = array();
        
        while ($local = mysql_fetch_array($local_list)){
          $result[] = $local;
        }
        return $result;
}

//cap nhat 
function editphongnghi($id, $local)
{
    mysql_query("update phong_nghi set
    title = '".$local['title']."',
    menu = '".$local['menu']."',
    sap_xep = '".$local['sap_xep']."',
    edit_date = NOW(),
    content = '".$local['content']."'
    where phong_nghi_id = '".(int)$id."'", dbconnect());
}
// xoa 
function delphongnghi($id){
    mysql_query("delete from phong_nghi where id ='".(int)$id."'", dbconnect());
}

function totalphongnghi(){
   $result = mysql_query("select * from phong_nghi",dbconnect());
   return mysql_num_rows($result);
}
    

?>